package com.design.alex.builder;

import java.util.ArrayList;
import java.util.List;

public class Meal {
    public List<Item> items = new ArrayList<>();

    public void addItem(Item item) {
        items.add(item);
    }

    public float getCost() {
        final float[] cost = {0.0F};
        items.forEach(i -> cost[0] = cost[0] + i.price());
        return cost[0];
    }

    public void showItems() {
        items.forEach(item -> {
            System.out.print("item: " + item.name());
            System.out.print(", Packing: " + item.packing());
            System.out.println(", Price: " + item.price());
        });
    }
}
